package com.haoxi.gateway.cmpp30msg;

/**
 * Title:CMPP3.0,2004.09
 */

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;


/**
 * ʵ��CMPP3.0 CMPP_TERMINATE_REP
 */
public class CMPPTerminateRep {
    private byte[] bytes;

    /**
     * ����һ��CMPP_TERMINATE_REP
     *
     * @param SequenceID ��Ϣ���к�
     */
    public CMPPTerminateRep ( int SequenceID ) {
        CMPPMsgHead head = new CMPPMsgHead ( CMPPCommon.MSG_HEAD_LENGTH, CMPPCommon.CMPP_TERMINATE_REP, SequenceID );
        bytes = head.getMsgHead ();
    }

    /**
     * ����һ��CMPP_TERMINATE_REP
     */
    public CMPPTerminateRep () {
    }

    /**
     * ��CMPP_TERMINATER_REP�����ֽ��������ʽ���
     *
     * @param out �����
     * @throws IOException ��IOΥ��ʱ
     */
    public void write ( OutputStream out ) throws IOException {
        if ( bytes == null ) {
            throw new IOException ( "CMPP_TERMINATE_REP bytes is NULL" );
        }
        out.write ( bytes );
        out.flush ();
    }

    /**
     * ���ֽ����鷽ʽ��ȡCMPP_TERMINATE_REP��
     *
     * @param in ������
     * @throws IOException ��IOΥ��ʱ
     */
    public void read ( InputStream in ) throws IOException {
        CMPPMsgHead head = new CMPPMsgHead ();
        head.read ( in );
        bytes = head.getMsgHead ();
    }

    /**
     * ���ֽ�������ʽ����CMPP_TERMINATE_REP
     *
     * @return �ֽ�������ʽ��CMPP_TERMINATE_REP
     */
    public byte[] getBytes () {
        return bytes;
    }
}